# 需求:通过用户输入的姓名或者年龄来查询用户信息
# 导入pymysql
import pymysql

# 创建连接对象
conn = pymysql.connect(host='localhost', user='root', password='root', database='advanced', port=3306, charset='utf8')

# 获取游标对象
cursor = conn.cursor()

# 执行sql语句
name = input('姓名:')
age = input('年龄:')

sql = 'select * from student where stu_name = %s or stu_age = %s'
rows = cursor.execute(sql, [name, age])

# 获取结果集
if rows:
    print(cursor.fetchall())
else:
    print('没有要查找的学生')

# 关闭资源
cursor.close()
conn.close()
